<template>
	<el-breadcrumb separator="/" style="padding-top: 4px; margin-left: 20px;">
		<el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
		<el-breadcrumb-item v-for="(item,index) in routeArr" :key="index">{{item}}</el-breadcrumb-item>
	</el-breadcrumb>
</template>

<script>
export default {
	data() {
		return {
            routeArr:[]
        }
	},
	watch:{
        $route:{
            handler(route){
                if(route.path === '/index'){
                    this.routeArr = []
                    return
                }
                console.log('route ',route)
                // 获取当前路由信息对象route中matched数组路由信息 保存到新数组中
                let routeArr = route.matched.map(item=>item.meta.title)
                this.routeArr = routeArr
            }
        }
    }
}
</script>
<style scoped lang="scss">
</style>

